package com.yuchen.ishop.service.admin;

import com.yuchen.core.MyPager;
import com.yuchen.core.jdbc.BaseDao;
import com.yuchen.ishop.Gobals;
import com.yuchen.ishop.entity.<%= beanInfo.classname%>;
import org.nutz.dao.Cnd;
import org.nutz.dao.Condition;
import org.nutz.dao.sql.Criteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class <%= beanInfo.classname%>ServiceImpl implements <%= beanInfo.classname%>Service{

    @Autowired
    private BaseDao dao;

     //@Override
     //public List find() {
         //Condition c = Cnd.where("dicKey", "=", Gobals.SYS_GOODS_TYPE_KEY).asc("sort");
         //return dao.query(<%= beanInfo.classname%>.class,null);
    // }
    
    @Override
    public MyPager find(Map params, MyPager pager) {
            Criteria cri = Cnd.cri();
            /*if(StringUtils.isNotBlank((String) params.get("name"))){
                        cri.where().andEquals("name",params.get("name"));
                    }
                    if(StringUtils.isNotBlank((String) params.get("state"))){
                        cri.where().andEquals("state",params.get("state"));
                    }
                    if(StringUtils.isNotBlank((String) params.get("identification"))){
                        cri.where().andEquals("identification",params.get("identification"));
                    }*/
            return dao.queryPager(<%= beanInfo.classname%>.class,cri,pager);
    }

    @Override
    public <%= beanInfo.classname%> insert(<%= beanInfo.classname%> <%= beanInfo.alias%>) {

        return dao.insert(<%= beanInfo.alias%>);
    }

    @Override
    public int update(<%= beanInfo.classname%> <%= beanInfo.alias%>,boolean isIgnoreNull) {
        if(isIgnoreNull) return dao.updateIgnoreNull(<%= beanInfo.alias%>);
        return dao.update(<%= beanInfo.alias%>);
    }

    @Override
    public <%= beanInfo.classname%> getById(Long id) {
        return dao.fetch(<%= beanInfo.classname%>.class,id);
    }

    @Override
    public int delete(Long id) {
        return dao.delete(<%= beanInfo.classname%>.class,id);
    }


}
